/*! \file
 * \brief Enter a brief description here.
 *
 * Enter a detailed description here. (optional)
 * \author Author (Ivo Wingelaar)
 * \date Date (2011)
 * \version Version (0.0.1)
 * \copyright Copyright (GNU LGPL v3)
 */

#ifndef __LYNX_WINDOW_MANAGER_STUB_C_HPP_INCLUDED__
#define __LYNX_WINDOW_MANAGER_STUB_C_HPP_INCLUDED__

#include "LynxWindowManager.hpp"

namespace Lynx
{

/** class               **/
/** WindowManagerStub_C **/
//! An stub implementation of the WindowManager.
class WindowManagerStub_C : public WindowManager
{
public:
    /** constructor **/
    /// \param    const WindowParameters& parameters
    ///         The parameters you want to use for this window.
    WindowManagerStub_C(const WindowParameters& parameters);

    /** default destructor **/
    virtual ~WindowManagerStub_C();

    /** virtual function      **/
    /** set_double_click_time **/
    //! Sets the double click time.
    /// \return void
    /// \param    uint32_t time_ms
    ///         The double click time in milliseconds.
    virtual void set_double_click_time(uint32_t time_ms);

    /** const virtual function **/
    /** get_double_click_time  **/
    //! Returns the double click time.
    /// \return uint32_t
    ///         The double click time.
    /// \param  void
    virtual uint32_t get_double_click_time(void) const;

    /** const virtual function **/
    /** is_window_fullscreen   **/
    //! Returns if the window is fullscreen.
    /// \return bool
    ///         True if the window is fullscreen, false otherwise.
    /// \param  void
    virtual bool is_window_fullscreen(void) const;

    /** virtual function     **/
    /** post_event_from_user **/
    //! Posts an event from the user.
    /// \return bool
    ///         True if the event was absorbed, false otherwise.
    /// \param    const Event &event
    ///         The event you want to post.
    virtual bool post_event_from_user(const Event& event);

    /** const virtual function **/
    /** get_event_receiver     **/
    //! Returns the eventreceiver.
    /// \return EventReceiver*
    ///         The eventreceiver.
    /// \param  void
    virtual EventReceiver* get_event_receiver(void) const;

    /** virtual function   **/
    /** set_event_receiver **/
    //! Sets a new eventreceiver.
    /// \return void
    /// \param    EventReceiver *receiver
    ///         A pointer to the new eventreceiver.
    virtual void set_event_receiver(EventReceiver* receiver);

    /** virtual function           **/
    /** add_event_receiving_object **/
    //! Adds a event receiving object to the eventlist.
    /// \return void
    /// \param    EventReceivingObject* object
    ///         A pointer to the event receiving object you want to add.
    virtual void add_event_receiving_object(EventReceivingObject* object);

    /** const virtual function           **/
    /** get_event_receiving_object_count **/
    //! Returns amount of event receiving object that are loaded.
    /// \return uint32_t
    ///         The total amount of event receiving objects.
    /// \param  void
    virtual uint32_t get_event_receiving_object_count(void) const;

    /** virtual function           **/
    /** get_event_receiving_object **/
    //! Returns a event receiving object.
    /// \return EventReceivingObject*
    /// \param    uint32_t index
    ///         A pointer to the event receiving object you want to add.
    virtual EventReceivingObject* get_event_receiving_object(uint32_t index) const;

    /** const virtual function **/
    /** get_video_manager      **/
    //! Returns the pointer to the videomanager.
    /// \return Video::VideoManager*
    ///         The pointer to the videomanager.
    /// \param  void
    virtual VideoManager* get_video_manager(void) const;

    virtual Audio::AudioManager* get_audio_manager(void) const;

    /** const virtual function **/
    /** get_log_manager        **/
    //! Returns the pointer to the logmanager.
    /// \return LogManager*
    ///         The pointer to the logmanager.
    /// \param  void
    virtual LogManager* get_log_manager(void) const;

    /** const virtual function **/
    /** get_time_manager       **/
    //! Returns the pointer to the timemanager.
    /// \return TimeManager*
    ///         The pointer to the timemanager.
    /// \param  void
    virtual TimeManager* get_time_manager(void) const;

    /** const virtual function **/
    /** get_cursor_manager     **/
    //! Returns the pointer to the cursormanager.
    /// \return CursorManager*
    ///         The pointer to the cursormanager.
    /// \param  void
    virtual CursorManager* get_cursor_manager(void) const;

    /** const virtual function **/
    /** get_os_manager         **/
    //! Returns the pointer to the osmanager.
    /// \return OSManager*
    ///         The pointer to the osmanager.
    /// \param  void
    virtual OSManager* get_os_manager(void) const;

protected:
    /** virtual function        **/
    /** check_successive_clicks **/
    //! Returns how many clicks where registered on a specific point.
    /// \return uint32_t
    ///         The number of clicks.
    /// \param    int32_t mouse_x
    ///         The x-coord of the mouse event.
    /// \param    int32_t mouse_y
    ///         The y-coord of the mouse event.
    /// \param    LYNX_E_MOUSE_EVENT input_event
    ///         The type of the event.
    virtual uint32_t check_successive_clicks(int32_t mouse_x,
            int32_t mouse_y,
            LYNX_E_MOUSE_EVENT input_event);

    /** function             **/
    /** calculate_gamma_ramp **/
    //! Helper function for calculation of the gamma ramp.
    /// \return void
    /// \param    uint16_t* ramp
    ///         The calculated ramp.
    /// \param    float gamma
    ///         The gamma value.
    /// \param    float relative_brightness
    ///         The relative brightness.
    /// \param    float relative_contrast
    ///         The relative contrast.
    void calculate_gamma_ramp(uint16_t* ramp,
                              float gamma,
                              float relative_brightness,
                              float relative_contrast);

    /** function                  **/
    /** calculate_gamma_from_ramp **/
    //! Calculates the gamma value from a ramp.
    /// \return void
    /// \param    float& gamma
    ///         The gamma value.
    /// \param    const uint16_t* ramp
    ///         The gamma ramp.
    void calculate_gamma_from_ramp(float& gamma,
                                   const uint16_t* ramp);

    WindowParameters mParameters;

    VideoManager* mVideoManager;
    Audio::AudioManager* mAudioManager;
    LogManager* mLogManager;
    TimeManager* mTimeManager;
    CursorManager* mCursorManager;
    OSManager* mOSManager;

    EventReceiver* mReceiver;
    std::vector<EventReceivingObject*> mEventObjects;
    bool mClose;

    struct MouseMultiClicks
    {
        MouseMultiClicks() :
            mDoubleClickTime(500),
            mCountSuccessiveClicks(0),
            mLastClickTime(0),
            mLastClick(0),
            mLastMouseInputEvent(EME_COUNT)
        {
            //
        }

        uint32_t mDoubleClickTime;
        uint32_t mCountSuccessiveClicks;
        uint32_t mLastClickTime;
        Myth::Math::Vector2i mLastClick;
        LYNX_E_MOUSE_EVENT mLastMouseInputEvent;
    };

    MouseMultiClicks mMouseMultiClicks;
};

} // namespace Lynx

#endif // __LYNX_WINDOW_MANAGER_STUB_C_HPP_INCLUDED__

